require.config({
               baseUrl:"../",
               paths:{
               bsl:'bsl',
               
               }
               });
require(['bsl'],function(bsl){
        document.addEventListener('deviceready', onDeviceready, false);
        
        function onDeviceready(){
        alert("star");
        
        function alerts() {
        var message = "变色龙提示";
        var title = "变色龙提示标题";
        var buttonCapture = "按钮内容";
        bsl.nativeUI.alert(onSuccess,message,title, buttonCapture);
        }
        
        function onSuccess(nativeUI) {
        var stetaStr = nativeUI["state"];
        document.getElementById('nativeUI').innerHTML= stetaStr
        }
        
        
        function confirm() {
        var message = "变色龙确认对话框";
        var title = "变色龙确认对话框标题";
        var buttonCapture = new Array();
        buttonCapture = ["取消","确认","ok"];
        bsl.nativeUI.confirm(onSuccess1,message,title, buttonCapture);
        }
        
        
        function onSuccess1(nativeUI) {
        var isSure = nativeUI["isSure"];
        var sureStr ;
        if (isSure == 0)
        {
            sureStr = "取消";
        }
        else if (isSure == 1)
        {
            sureStr = "确认";
        }
        else
        {
            sureStr = "ok";
        }
        document.getElementById('nativeUI').innerHTML= '弹出系统确认对话框:' + '<br />' + '按"' +sureStr + '"关闭';
        }
        
        function showWaiting() {
        var title = "变色龙弹出等待提示框";
        var width = 100;
        var height = 100;
        var color = "#DDDDDD";
        var size = 12;
        var textalign = "center";
        var padding = 0;
        var background = "#000000";
        var style = "white";
        var modal = false;
        var round = 10;
        var padlock = true;
        var times = 10;
        
        var waitingOptions = {"title":title,"width":width,"height":height,"color":color,"size":size,"textalign":textalign,"padding":padding,"background":background,"style":style,"modal":modal,"round":round,"padlock":padlock,"times":times};
        bsl.nativeUI.showWaiting(waitingOptions);
        }
        
        function actionSheet()
        {
        var title = "选择按钮框的标题";
        var cancel = "取消按钮文字";
        var buttons = new Array;
        buttons  = [cancel,"选择按钮1","选择按钮2","选择按钮3"];
        bsl.nativeUI.actionSheet(actionsheetCallback,title,buttons);
        }
        
        
        function actionsheetCallback(index)
        {
        
        document.getElementById('nativeUI').innerHTML= '弹出系统选择对话框:' + '<br />' + '按"' +index + '"按钮';
        }
        
        
        function pickDate()
        {
        bsl.nativeUI.pickDate(successCB,errorCB);

        }
        
        function pickTime()
        {
        bsl.nativeUI.pickTime(successCB,errorCB);

        }

        
        function successCB(date)
        {
        document.getElementById('nativeUI').innerHTML= '弹出时间对话框:' + '<br />' + '选择时间:'  + date;
        }


        
        function errorCB(error)
        {
        var code = error["code"];
        var message = error["message"];
        document.getElementById('nativeUI').innerHTML= '弹出时间对话框:' + '<br />' + '错误信息:' +'<br />' +'code:' + code + '<br />' + 'message:' + message;
        }
        
        function prompt()
        {
        var message = "请输入您的姓名";
        var title = "NativeUI";
        var tip = "请输入您的姓名(tip)";
        var buttons = new Array;
        buttons = ["取消","确定","OK"];
        
        
        bsl.nativeUI.prompt(promptCB,message,title,tip,buttons);
        }
        
        function promptCB(event)
        {
        var index = event["index"];
        var value = event["value"];
        document.getElementById('nativeUI').innerHTML= '弹出输入对话框:' + '<br />' + 'index:' + index + '<br />' + 'value:' + value;

        }
        
        document.getElementById("alerts").addEventListener("click",alerts,false);
        document.getElementById("confirm").addEventListener("click",confirm,false);
        document.getElementById("showWaiting").addEventListener("click",showWaiting,false);
        document.getElementById("actionSheet").addEventListener("click",actionSheet,false);
        document.getElementById("pickDate").addEventListener("click",pickDate,false);
        document.getElementById("pickTime").addEventListener("click",pickTime,false);
        document.getElementById("prompt").addEventListener("click",prompt,false);

        }
        
        
        });